Skip to content

Support prebuilt OpenApiOperation in EndpointMetadata#2404

Merged
domaindrivendev merged 1 commit into
domaindrivendev:masterfrom
captainsafia:safia/support-openapi-builtin
Apr 22, 2022
Merged

Support prebuilt OpenApiOperation in EndpointMetadata#2404
domaindrivendev merged 1 commit into
domaindrivendev:masterfrom
captainsafia:safia/support-openapi-builtin

Conversation

@captainsafia
Copy link
Copy Markdown
Collaborator

As part of the work outlined in dotnet/aspnetcore#40676 and implemented in dotnet/aspnetcore#41238, we're experimenting with providing a package that allows users to generate and modify OpenApiOperation metadata directly on endpoints.

In this new workflow, a user can annotate their endpoint like so:

app.MapGet("/foo", () => ...)
  .WithOpenApi();

Which will generate the OpenApiOperation directly and add it to the endpoint metadata. Users can also do:

app.MapGet("/foo", () => ...)
  .WithOpenApi(operation => {
     return modifyMyOperation(operation)
  });

Which will add an OpenApiOperation to metadata with the modifications that the user provides.

This PR checks to see if there already exists OpenApiOperation metadata for an endpoint and uses that over the generated variety.

@captainsafia
Copy link
Copy Markdown
Collaborator Author

@domaindrivendev Thoughts on this?

@domaindrivendev
Copy link
Copy Markdown
Owner

Hi @captainsafia - happy to merge this as it's relatively straightforward. However, I do have a couple of questions around the work outlined in dotnet/aspnetcore#40676:

  • If I'm understanding correctly, the longer term goal is to provide mapping of internal metadata to OpenApi types in a new package. Wouldn't this essentially replace the core of what Swashbuckle does? If so, that raises major questions around how much effort should continue going into Swashbuckle itself. cc @bradygaster
  • Furthermore, I believe (from many years of experience) that perfecting that mapping is extremely difficult, particulary when it get's into mapping C# models to OpenApiSchema instances, accounting for serializer behavior etc. So, interested to know exactly how far the new library will go. For example, will it account for serializer behavior, data annotations etc.?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants